package com.ctyon.watchmanager.ui.fragment;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;

import com.ctyon.common.util.TSnackbarUtil;
import com.ctyon.netlibrary.net.revert.BaseResponseEntity;
import com.ctyon.netlibrary.use.BaseObserver;
import com.ctyon.watchmanager.R;
import com.ctyon.watchmanager.databinding.FragmentStrangeBinding;
import com.ctyon.watchmanager.model.net.service.NetService;
import com.ctyon.watchmanager.ui.BaseFragment;
import com.orhanobut.logger.Logger;

import java.util.concurrent.TimeUnit;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * CreateDate：19-6-25 on 上午9:14
 * Describe:
 * Coder: lee
 */
public class StrangeCallFragment extends BaseFragment {

    public static final String TAG = "StrangeCallFragment";

    private FragmentStrangeBinding mBinding;

    public static StrangeCallFragment newInstance() {
        final StrangeCallFragment fragment = new StrangeCallFragment();
        final Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_strange, container, false);

        return mBinding.getRoot();

    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mBinding.strange.setOnCheckedChangeListener((buttonView, isChecked) -> {
            Log.d(LTAG, "onSwitchClick : " + isChecked);
        });
    }

    private void getState(){
        final String method = "smsNotification";
        if (NetService.getInstance().isDisable(method)) {
            TSnackbarUtil.TSBError(getActivity(), "请稍候...");
            return;
        }
//        NetService.getInstance()
//                .method(method)
//                .smsNotification(content)
//                .timeout(10, TimeUnit.SECONDS)
//                .subscribeOn(Schedulers.io())
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribe(new BaseObserver<BaseResponseEntity>() {
//                    @Override
//                    public void onSuccess(BaseResponseEntity responseEntity) {
//                        Logger.d("onSuccess : " + responseEntity.toString());
//                        TSnackbarUtil.TSBSuccess(getActivity(), "设置成功");
//                    }
//
//                    @Override
//                    public String onOver() {
//                        return method;
//                    }
//                });
    }

}
